/**
 * 获得分页栏
 * vPageSize 分页数
 * vStore Store对象
 */
function cf_getPagingToolbar(vPageSize,vStore) {
	var pageSize = (vPageSize == undefined || vPageSize == '') ? PAGING_PAGE_SIZE : vPageSize;
	var store = (vStore == undefined || vStore == '') ? '' : vStore;
	return new Ext.PagingToolbar({
        pageSize: pageSize,
        store: vStore,
        displayInfo: true,
        displayMsg: '<s:text name="com.messages.display.record"/> {0} - {1} of {2}',
        emptyMsg: '<s:text name="com.messages.display.norecord"/>'
    });
}

/**
 * 将数值四舍五入(保留1位小数)后格式化成金额形式
 * @param num 数值(Number或者String)
 * @return 金额格式的字符串,如'1,234,567.4'
 * @type String
 */
function cf_formatCurrencyTenThou(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    	num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    	cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    	num = num.substring(0,num.length-(4*i+3))+','+
    		num.substring(num.length-(4*i+3));
    return (((sign)?'':'-') + num + '.' + cents);
}

/**
 * 显示消息进度
 * msg 消息内容
 */
function cf_ShowMessageBox(msg) { 
  	Ext.MessageBox.show({
	  	msg: msg,
	    progressText: '',
		width: 200,
		progress: true,
		wait: true,
		waitConfig: {interval:200},
		//closable: false,
		animEl: 'loading',
		icon: Ext.MessageBox.INFO
  	});	
}

//从数据指定位置插入新对象
Array.prototype.insert = function(index,obj) {
  	this.splice(index,0,obj);
}
//删除指定的对象
Array.prototype.removeAt = function(index) {
  	this.splice(index,1);
}
//删除指定对象
Array.prototype.remove = function(obj) {
  	var index = this.indexOf(obj);
  	if (index >= 0)
    	this.removeAt(index);
}
//清空数据
Array.prototype.removeAll = function() {
  	this.splice(0,this.length);
}

/**
 * 验证表格中指定列的数值是否合理，使用时需要指定当前页面中的grid和column对象,且需要验证的column必须要定义id
 */
function cf_validateGrid(grid,column,columnArray) {
	if (columnArray == undefined || columnArray == '')
		return true;
	for (var i = 0; i < columnArray.length; i++) { //多个列验证的循环
		for(var j = 0,length = grid.getStore().getCount(); j < length; j++){
			//待验证的column必须要有id，否则这里会由于找不到id而出错
			if (column.getIndexById(columnArray[i]) == -1) {
				Ext.MessageBox.alert('提示','找不到列名' + ':' + columnArray[i]);
				return;					
			}
			var gridValue;
			if (Ext.isIE)
				gridValue = grid.getView().getCell(j,column.getIndexById(columnArray[i])).firstChild.innerText;
			else
			 	gridValue = grid.getView().getCell(j,column.getIndexById(columnArray[i])).firstChild.textContent;
			if (gridValue.trim() == '') {
				var columnHeader = column.getColumnHeader(column.getIndexById(columnArray[i]));
				var message = '';
				if (columnHeader != '')
					message = columnHeader + '为必填项,不能为空!';
				 else 
					message = '必填项不能为空!';
				Ext.MessageBox.alert('提示', message,
				function(btn) {
					if (btn == BUTTON_OK)
						grid.startEditing(j,column.getIndexById(columnArray[i]));
				});
				return;
			}
		}
	}
	return true;
}











